﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Entity;

namespace BLL
{
    public class NewsContent
    {
        DAL.NewsContent dal = new DAL.NewsContent();
        /// <summary>
        /// 得到NewsContent列表
        /// </summary>
        /// <returns>返回NewsContent列表</returns>
        public DataTable GetNewsContent() {
            return dal.GetNewsContent();
        }
        /// <summary>
        /// 修改一条数据
        /// </summary>
        /// <param name="model">新闻模型</param>
        public void UpdateRow(BoNewsContent model)
        {
            dal.UpdateRow(model);
        }
        /// <summary>
        /// 添加一条记录
        /// </summary>
        /// <param name="model">实体类</param>
        /// <returns></returns>
        public void Insert(BoNewsContent model)
        {
            model.NewsId = System.Guid.NewGuid().ToString();
            dal.Insert(model);
        }

        
         /// <summary>
        /// 根据id获取一条数据
        /// </summary>
        /// <param name="id">id号</param>
        /// <returns>返回获取到的数据</returns>
        public BoNewsContent GetNewsSingle(string id) 
        {
            return dal.GetNewsSingle(id);
        }



        /// <summary>
        /// 删除一行
        /// </summary>
        /// <param name="id">此行的id</param>
        /// <returns>返回删除的行数</returns>
        public int DelData(string id) {
            return dal.DelData(id);
        }

        /// <summary>
        /// 通过竞赛id来删除与之相对应的内容信息
        /// </summary>
        /// <param name="classId"></param>
        /// <returns>返回受影响的行数</returns>
        public int DeleteByClassId(string classId)
        {
            return dal.DeleteByClassId(classId);
        }
        /// <summary>
        /// 根据条件查询前几行数据
        /// </summary>
        /// <param name="rowNb">行数</param>
        /// <param name="sqlCon">查询条件</param>
        /// <param name="orderCon">排序条件</param>
        /// <returns>返回前几行数据</returns>
        public DataTable GetRows(int rowNb, string sqlCon, string orderCon) {
            return dal.GetRows(rowNb, sqlCon, orderCon);
        }

        /// <summary>
        /// 根据视图得到所有的新闻列表
        /// </summary>
        /// <returns></returns>
        public List<BoNewsContent> GetNews(object sqlcon)
        {
            return dal.GetNews(sqlcon);
        }
        /// <summary>
        /// 根据数据行数获取表格
        /// </summary>
        /// <param name="start">开始数据条数</param>
        /// <param name="end">结束数据集条数</param>
        /// <param name="sqlcon">查询条件</param>
        /// <returns>返回相应的表格</returns>
        public DataTable GetPage(string start, string end, string orderCon,string sqlcon)
        {
            return dal.GetPage(start, end, orderCon,sqlcon);
        }
    }
}
